package com.company;

import java.util.Scanner;

public class Sense {
    private Person person=new Person();
    private MonsterWolf wolf1=new MonsterWolf();
    private MonsterWolf wolf2=new MonsterWolf();
    private MonsterWolf wolf3=new MonsterWolf();
    private MonsterWolfSet monsterWolfSet=new MonsterWolfSet();
    Ui ui=new Ui();
    public void initSense()
    {
        initMonster();
        initPerson();


    }
    public void initPerson()
    {
        person.setId("001");
        person.setDescription("小虎");
        person.setHPValue(200);
        person.setCurrentWeapon(new WeaponSword("WS",
                "双子剑",
                -30)
        );
    }
    public void initMonster(){
        wolf1.setId("wolf1");
        wolf1.setDescription("狼1");
        wolf1.setHPValue(100);
        wolf1.setCurrentWeapon(new WeaponKnife("WK1",
                "妖刀1",
                -40)
        );
        wolf2.setId("wolf2");
        wolf2.setDescription("狼2");
        wolf2.setHPValue(100);
        wolf2.setCurrentWeapon(new WeaponKnife("WK2",
                "妖刀2",
                -40)
        );
        wolf3.setId("wolf3");
        wolf3.setDescription("狼3");
        wolf3.setHPValue(100);
        wolf3.setCurrentWeapon(new WeaponKnife("WK3",
                "妖刀3",
                -40)
        );
        monsterWolfSet.getMonsterWolves().add(wolf1);
        monsterWolfSet.getMonsterWolves().add(wolf2);
        monsterWolfSet.getMonsterWolves().add(wolf3);


    }



    public void play()
    {
        ui.displayStaus(this);
        ui.displayHelpMsg();
        Scanner in=new Scanner(System.in);
        while (true){
            String command=in.nextLine();
            String[] words=command.split(" ");
            if(words[0].equals("bye"))
            {

                ui.displayBye();
               System.exit(0);
            }
            else if(words[0].equals("help")){
                ui.displayHelpMsg();
            }else if(words[0].equals("chop")){
                this.getPerson().useArticle(getPerson().getCurrentWeapon(),
                        this.getMonsterWolfSet().get(words[1]));
                ui.displayDamageMsg(this.getPerson(),this.getMonsterWolfSet().get(words[1]));
                for(MonsterWolf item:this.getMonsterWolfSet().getMonsterWolves()
                ){
                    if(1==Utils.randomMonsterChop(0,2))
                    {
                        item.useArticle(item.getCurrentWeapon(),this.getPerson());
                        ui.displayDamageMsg(item,getPerson());
                    }
                    else{

                     }
                }

            }
            else{
                ui.displayErrorCmdMsg();
                ui.displayHelpMsg();
            }
            ui.displayStaus(this);
      }
 }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public MonsterWolfSet getMonsterWolfSet() {
        return monsterWolfSet;
    }

    public void setMonsterWolfSet(MonsterWolfSet monsterWolfSet) {
        this.monsterWolfSet = monsterWolfSet;
    }
}
